package com.wc.alorithm_luogu._动态规划.P1028;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/7/20 22:04
 * @description [NOIP2001 普及组] 数的计算
 * https://www.luogu.com.cn/problem/P1028
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] dp = new int[n + 1];

        dp[1] = 1;

        if (n >= 2) {
            dp[2] = 2;
        }

        if (n >= 3) {
            dp[3] = dp[2];
        }
        for (int i = 4; i <= n; i++) {
            if (i % 2 == 0) {
                dp[i] = dp[i / 2] + dp[i - 2];
            } else {
                dp[i] = dp[i - 1];
            }
        }
        System.out.println(dp[n]);
    }
}
